﻿using System;
using Cirrious.MvvmCross.Interfaces.ViewModels;
using Cirrious.MvvmCross.Platform.Diagnostics;
using Cirrious.MvvmCross.ViewModels;
using TeaLightV5.Foundation.MvvmCross.Views;

namespace TeaLightV5.Foundation.MvvmCross.ViewModels
{
    public abstract class TeaViewModel : MvxViewModel
    {
        protected bool RequestNavigate<TViewModel>(ITeaViewModelParameters parameters) where TViewModel : IMvxViewModel
        {
            return RequestNavigate(typeof(TViewModel), false, MvxRequestedBy.UserAction, parameters);
        }

        protected bool RequestNavigate(Type viewModelType, bool clearTop, MvxRequestedBy requestedBy, ITeaViewModelParameters parameters)
        {
            MvxTrace.TaggedTrace("Navigation", "Navigate to " + viewModelType.Name + " with args");
            if (ViewDispatcher != null)
                return ViewDispatcher.RequestNavigate(new TeaShowViewModelRequest(
                                                          viewModelType,
                                                          clearTop,
                                                          requestedBy,
                                                          parameters));

            return false;
        }

    }
}
